0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 629 ms)
↳10 BOUNDS(1, n^2)
cond1(true, x, y) → cond2(gr(x, y), x, y)
cond2(true, x, y) → cond1(neq(x, 0), y, y)
cond2(false, x, y) → cond1(neq(x, 0), p(x), y)
gr(0, x) → false
gr(s(x), 0) → true
gr(s(x), s(y)) → gr(x, y)
neq(0, 0) → false
neq(0, s(x)) → true
neq(s(x), 0) → true
neq(s(x), s(y)) → neq(x, y)
p(0) → 0
p(s(x)) → x
cond1(true, x, y) → cond2(gr(x, y), x, y) [1]
cond2(true, x, y) → cond1(neq(x, 0), y, y) [1]
cond2(false, x, y) → cond1(neq(x, 0), p(x), y) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
neq(0, 0) → false [1]
neq(0, s(x)) → true [1]
neq(s(x), 0) → true [1]
neq(s(x), s(y)) → neq(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond1(true, x, y) → cond2(gr(x, y), x, y) [1]
cond2(true, x, y) → cond1(neq(x, 0), y, y) [1]
cond2(false, x, y) → cond1(neq(x, 0), p(x), y) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
neq(0, 0) → false [1]
neq(0, s(x)) → true [1]
neq(s(x), 0) → true [1]
neq(s(x), s(y)) → neq(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond1 :: true:false → 0:s → 0:s → cond1:cond2 true :: true:false cond2 :: true:false → 0:s → 0:s → cond1:cond2 gr :: 0:s → 0:s → true:false neq :: 0:s → 0:s → true:false 0 :: 0:s false :: true:false p :: 0:s → 0:s s :: 0:s → 0:s |
cond1(v0, v1, v2) → null_cond1 [0]
null_cond1
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
0 => 0
false => 0
null_cond1 => 0
cond1(z, z', z'') -{ 1 }→ cond2(gr(x, y), x, y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
cond1(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
cond2(z, z', z'') -{ 1 }→ cond1(neq(x, 0), y, y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
cond2(z, z', z'') -{ 1 }→ cond1(neq(x, 0), p(x), y) :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
gr(z, z') -{ 1 }→ gr(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gr(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
gr(z, z') -{ 1 }→ 0 :|: z' = x, x >= 0, z = 0
neq(z, z') -{ 1 }→ neq(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
neq(z, z') -{ 1 }→ 1 :|: z' = 1 + x, x >= 0, z = 0
neq(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
neq(z, z') -{ 1 }→ 0 :|: z = 0, z' = 0
p(z) -{ 1 }→ x :|: x >= 0, z = 1 + x
p(z) -{ 1 }→ 0 :|: z = 0
eq(start(V, V1, V2),0,[cond1(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[cond2(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[gr(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2),0,[neq(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2),0,[p(V, Out)],[V >= 0]). eq(cond1(V, V1, V2, Out),1,[gr(V3, V4, Ret0),cond2(Ret0, V3, V4, Ret)],[Out = Ret,V1 = V3,V2 = V4,V = 1,V3 >= 0,V4 >= 0]). eq(cond2(V, V1, V2, Out),1,[neq(V5, 0, Ret01),cond1(Ret01, V6, V6, Ret1)],[Out = Ret1,V1 = V5,V2 = V6,V = 1,V5 >= 0,V6 >= 0]). eq(cond2(V, V1, V2, Out),1,[neq(V7, 0, Ret02),p(V7, Ret11),cond1(Ret02, Ret11, V8, Ret2)],[Out = Ret2,V1 = V7,V2 = V8,V7 >= 0,V8 >= 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 0,V1 = V9,V9 >= 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 1,V10 >= 0,V = 1 + V10,V1 = 0]). eq(gr(V, V1, Out),1,[gr(V11, V12, Ret3)],[Out = Ret3,V1 = 1 + V12,V11 >= 0,V12 >= 0,V = 1 + V11]). eq(neq(V, V1, Out),1,[],[Out = 0,V = 0,V1 = 0]). eq(neq(V, V1, Out),1,[],[Out = 1,V1 = 1 + V13,V13 >= 0,V = 0]). eq(neq(V, V1, Out),1,[],[Out = 1,V14 >= 0,V = 1 + V14,V1 = 0]). eq(neq(V, V1, Out),1,[neq(V15, V16, Ret4)],[Out = Ret4,V1 = 1 + V16,V15 >= 0,V16 >= 0,V = 1 + V15]). eq(p(V, Out),1,[],[Out = 0,V = 0]). eq(p(V, Out),1,[],[Out = V17,V17 >= 0,V = 1 + V17]). eq(cond1(V, V1, V2, Out),0,[],[Out = 0,V18 >= 0,V2 = V19,V20 >= 0,V = V18,V1 = V20,V19 >= 0]). input_output_vars(cond1(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(cond2(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(gr(V,V1,Out),[V,V1],[Out]). input_output_vars(neq(V,V1,Out),[V,V1],[Out]). input_output_vars(p(V,Out),[V],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [neq/3]
1. non_recursive : [p/2]
2. recursive : [gr/3]
3. recursive : [cond1/4,cond2/4]
4. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into neq/3
1. SCC is partially evaluated into p/2
2. SCC is partially evaluated into gr/3
3. SCC is partially evaluated into cond2/4
4. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations neq/3
* CE 18 is refined into CE [21]
* CE 17 is refined into CE [22]
* CE 16 is refined into CE [23]
* CE 15 is refined into CE [24]
### Cost equations --> "Loop" of neq/3
* CEs [22] --> Loop 15
* CEs [23] --> Loop 16
* CEs [24] --> Loop 17
* CEs [21] --> Loop 18
### Ranking functions of CR neq(V,V1,Out)
* RF of phase [18]: [V,V1]
#### Partial ranking functions of CR neq(V,V1,Out)
* Partial RF of phase [18]:
- RF of loop [18:1]:
V
V1
### Specialization of cost equations p/2
* CE 20 is refined into CE [25]
* CE 19 is refined into CE [26]
### Cost equations --> "Loop" of p/2
* CEs [25] --> Loop 19
* CEs [26] --> Loop 20
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations gr/3
* CE 10 is refined into CE [27]
* CE 9 is refined into CE [28]
* CE 8 is refined into CE [29]
### Cost equations --> "Loop" of gr/3
* CEs [28] --> Loop 21
* CEs [29] --> Loop 22
* CEs [27] --> Loop 23
### Ranking functions of CR gr(V,V1,Out)
* RF of phase [23]: [V,V1]
#### Partial ranking functions of CR gr(V,V1,Out)
* Partial RF of phase [23]:
- RF of loop [23:1]:
V
V1
### Specialization of cost equations cond2/4
* CE 14 is refined into CE [30,31]
* CE 13 is refined into CE [32,33,34,35]
* CE 12 is refined into CE [36,37]
* CE 11 is refined into CE [38,39]
### Cost equations --> "Loop" of cond2/4
* CEs [37] --> Loop 24
* CEs [36] --> Loop 25
* CEs [39] --> Loop 26
* CEs [38] --> Loop 27
* CEs [31] --> Loop 28
* CEs [30] --> Loop 29
* CEs [35] --> Loop 30
* CEs [34] --> Loop 31
* CEs [33] --> Loop 32
* CEs [32] --> Loop 33
### Ranking functions of CR cond2(V,V1,V2,Out)
* RF of phase [31]: [V1-1]
#### Partial ranking functions of CR cond2(V,V1,V2,Out)
* Partial RF of phase [31]:
- RF of loop [31:1]:
V1-1
### Specialization of cost equations start/3
* CE 2 is refined into CE [40]
* CE 3 is refined into CE [41,42,43,44,45]
* CE 4 is refined into CE [46,47,48,49,50,51,52]
* CE 5 is refined into CE [53,54,55,56]
* CE 6 is refined into CE [57,58,59,60,61,62]
* CE 7 is refined into CE [63,64]
### Cost equations --> "Loop" of start/3
* CEs [60] --> Loop 34
* CEs [45,52] --> Loop 35
* CEs [40,42,43,44,51] --> Loop 36
* CEs [41,50,54,55,56,59,61,62,64] --> Loop 37
* CEs [46,47,48,49,53,57,58,63] --> Loop 38
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of neq(V,V1,Out):
* Chain [[18],17]: 1*it(18)+1
Such that:it(18) =< V
with precondition: [Out=0,V=V1,V>=1]
* Chain [[18],16]: 1*it(18)+1
Such that:it(18) =< V
with precondition: [Out=1,V>=1,V1>=V+1]
* Chain [[18],15]: 1*it(18)+1
Such that:it(18) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [17]: 1
with precondition: [V=0,V1=0,Out=0]
* Chain [16]: 1
with precondition: [V=0,Out=1,V1>=1]
* Chain [15]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of p(V,Out):
* Chain [20]: 1
with precondition: [V=0,Out=0]
* Chain [19]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of gr(V,V1,Out):
* Chain [[23],22]: 1*it(23)+1
Such that:it(23) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[23],21]: 1*it(23)+1
Such that:it(23) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [22]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [21]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of cond2(V,V1,V2,Out):
* Chain [[31],33,27]: 5*it(31)+1*s(3)+8
Such that:aux(3) =< V1
it(31) =< aux(3)
s(3) =< it(31)*aux(3)
with precondition: [V=0,Out=0,V1>=2,V2+1>=V1]
* Chain [[31],26]: 5*it(31)+1*s(3)+3
Such that:aux(4) =< V1
it(31) =< aux(4)
s(3) =< it(31)*aux(4)
with precondition: [V=0,Out=0,V1>=2,V2+1>=V1]
* Chain [33,27]: 8
with precondition: [V=0,V1=1,Out=0,V2>=0]
* Chain [32,29,27]: 12
with precondition: [V=0,V2=0,Out=0,V1>=2]
* Chain [32,24]: 7
with precondition: [V=0,V2=0,Out=0,V1>=2]
* Chain [30,28,[31],33,27]: 7*it(31)+1*s(3)+17
Such that:aux(6) =< V2
it(31) =< aux(6)
s(3) =< it(31)*aux(6)
with precondition: [V=0,Out=0,V2>=2,V1>=V2+2]
* Chain [30,28,[31],26]: 7*it(31)+1*s(3)+12
Such that:aux(8) =< V2
it(31) =< aux(8)
s(3) =< it(31)*aux(8)
with precondition: [V=0,Out=0,V2>=2,V1>=V2+2]
* Chain [30,28,33,27]: 2*s(4)+17
Such that:aux(9) =< 1
s(4) =< aux(9)
with precondition: [V=0,V2=1,Out=0,V1>=3]
* Chain [30,28,26]: 2*s(4)+12
Such that:aux(10) =< V2
s(4) =< aux(10)
with precondition: [V=0,Out=0,V2>=1,V1>=V2+2]
* Chain [30,24]: 1*s(5)+7
Such that:s(5) =< V2
with precondition: [V=0,Out=0,V2>=1,V1>=V2+2]
* Chain [29,27]: 7
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [28,[31],33,27]: 6*it(31)+1*s(3)+12
Such that:aux(5) =< V2
it(31) =< aux(5)
s(3) =< it(31)*aux(5)
with precondition: [V=1,Out=0,V1>=1,V2>=2]
* Chain [28,[31],26]: 6*it(31)+1*s(3)+7
Such that:aux(7) =< V2
it(31) =< aux(7)
s(3) =< it(31)*aux(7)
with precondition: [V=1,Out=0,V1>=1,V2>=2]
* Chain [28,33,27]: 1*s(4)+12
Such that:s(4) =< 1
with precondition: [V=1,V2=1,Out=0,V1>=1]
* Chain [28,26]: 1*s(4)+7
Such that:s(4) =< V2
with precondition: [V=1,Out=0,V1>=1,V2>=1]
* Chain [27]: 3
with precondition: [V=0,V1=0,Out=0,V2>=0]
* Chain [26]: 3
with precondition: [V=0,Out=0,V1>=1,V2>=0]
* Chain [25]: 2
with precondition: [V=1,V1=0,Out=0,V2>=0]
* Chain [24]: 2
with precondition: [V=1,Out=0,V1>=1,V2>=0]
#### Cost of chains of start(V,V1,V2):
* Chain [38]: 17*s(30)+10*s(31)+2*s(32)+2*s(33)+2*s(35)+17
Such that:s(34) =< 1
s(28) =< V1
s(29) =< V2
s(35) =< s(34)
s(30) =< s(29)
s(31) =< s(28)
s(32) =< s(31)*s(28)
s(33) =< s(30)*s(29)
with precondition: [V=0]
* Chain [37]: 2*s(36)+2*s(37)+5
Such that:aux(14) =< V
aux(15) =< V1
s(36) =< aux(14)
s(37) =< aux(15)
with precondition: [V>=1]
* Chain [36]: 11*s(43)+44*s(46)+2*s(48)+6*s(49)+19
Such that:aux(16) =< V1
aux(18) =< V2
s(46) =< aux(18)
s(49) =< s(46)*aux(18)
s(43) =< aux(16)
s(48) =< s(43)*aux(16)
with precondition: [V>=0,V1>=0,V2>=0]
* Chain [35]: 17
with precondition: [V=1,V2=1,V1>=1]
* Chain [34]: 1*s(60)+1
Such that:s(60) =< V1
with precondition: [V=V1,V>=1]
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [38] with precondition: [V=0]
- Upper bound: nat(V1)*10+19+nat(V1)*2*nat(V1)+nat(V2)*17+nat(V2)*2*nat(V2)
- Complexity: n^2
* Chain [37] with precondition: [V>=1]
- Upper bound: 2*V+5+nat(V1)*2
- Complexity: n
* Chain [36] with precondition: [V>=0,V1>=0,V2>=0]
- Upper bound: 11*V1+19+2*V1*V1+44*V2+6*V2*V2
- Complexity: n^2
* Chain [35] with precondition: [V=1,V2=1,V1>=1]
- Upper bound: 17
- Complexity: constant
* Chain [34] with precondition: [V=V1,V>=1]
- Upper bound: V1+1
- Complexity: n
### Maximum cost of start(V,V1,V2): max([16,nat(V1)+4+max([2*V,nat(V1)*8+14+nat(V1)*2*nat(V1)+nat(V2)*17+nat(V2)*2*nat(V2)+ (nat(V2)*27+nat(V1)+nat(V2)*4*nat(V2))])+nat(V1)])+1
Asymptotic class: n^2
* Total analysis performed in 489 ms.